<?php

/* Register some assets (css/js) using WP functions so they can be enqueued on demand and cleanly */

add_action('init', 'register_assets');

function register_assets() {
  
  wp_register_style( 'style_login', get_bloginfo( 'template_directory' ). '/css/login.css' );
  wp_register_style( 'theme_style', get_bloginfo( 'template_directory' ). '/style.css' );
  wp_register_style( 'frontend_app_style', get_bloginfo( 'template_directory' ). '/css/front-end_app.css' );
  wp_register_script( 'frontend_app_js', plugins_url( 'js/front-end_app.js' , dirname( __FILE__ ) ), array( 'jquery', 'jquery-ui-core' ) );
  wp_register_script( 'jquery_loadImages', plugins_url( 'js/jquery/jquery.loadImages.1.0.1.min.js' , dirname( __FILE__ ) ), array( 'jquery' ), '1.0.1' );
  wp_register_script( 'js_shortcut', plugins_url( 'js/shortcut.js' , dirname( __FILE__ ) ), array( 'jquery' ), '0.7.9' );
  wp_register_script( 'jquery_cycle_lite', plugins_url( 'js/jquery/jquery.cycle.lite.js' , dirname( __FILE__ ) ), array( 'jquery' ), '1.3' );
  
  wp_enqueue_script( 'jquery' );
  wp_enqueue_script( 'jquery-ui-core' );
  //you know jquery is the bomb.
  
  if ( ! is_admin() &&
       ! in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ) {
    
    wp_enqueue_style( 'theme_style' );
    add_action ( 'wp_head', 'add_lonely_js_css' );
		
	}
  
}

/* Following are the function defenitions for all enqueuing situations for cleanliness of the source */

function add_lonely_js_css() { ?>

<!--[if lte IE 6]>
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/css/ie/style_ie6.css" type="text/css" />
<script type="text/javascript">
	/* <![CDATA[ */
	
	jQuery(document).ready(function($){
		
		$.fx.off = true;
		
	});
	
	/* ]]> */
</script>
<![endif]-->

<script type="text/javascript">
  /* <![CDATA[ */
  
  template_directory = "<?php bloginfo('template_directory'); ?>";
  siteurl = "<?php bloginfo('url'); ?>";
  
  /* ]]> */
</script>

<?php

}

function add_login_css() {
  
  wp_enqueue_style( 'style_login' );
  
}

function add_frontend_app_css() {
  
  wp_enqueue_style( 'frontend_app_style' );
  
}

function add_frontend_app_js() {
  
  wp_enqueue_script( 'frontend_app_js' );
  wp_enqueue_script( 'jquery_loadImages' );
  wp_enqueue_script( 'jquery_cycle_lite' );
  wp_enqueue_script( 'js_shortcut' );
  wp_localize_script( 'frontend_app_js', 'i18n', array(
    'ajaxurl' => admin_url('admin-ajax.php'),
    'bloginfo_name' => get_bloginfo( 'name' ),
    'welcome' => sprintf( __( 'WELCOME TO %s!' , 'wordpress-word-trainer'), get_bloginfo('name') ),
    'status_learn' => __( 'Type the letters to spell the word.' , 'wordpress-word-trainer'),
    'status_study' => __( 'Do you know what that picture is?' , 'wordpress-word-trainer'),
    'well_done' => __( 'Well done!' , 'wordpress-word-trainer'),
    'score_not_saved' => __( 'Your SCORE was not saved.' , 'wordpress-word-trainer') .' '. __( 'Please ask your TEACHER or supervisor for help.' , 'wordpress-word-trainer'),
    'ajax_error' => __( 'An error occured while fetching data. Please try again.' , 'wordpress-word-trainer'),
    'what_do_you_want_to_do' => __( 'What do you want to do?' , 'wordpress-word-trainer'),
    'learn' => __( 'Learn' , 'wordpress-word-trainer'),
    'study' => __( 'Study' , 'wordpress-word-trainer'),
    'test' => __( 'Test' , 'wordpress-word-trainer'),
    'no_words_found' => __( 'NO WORDS were found.' , 'wordpress-word-trainer') .' '. __( 'Please ask your TEACHER or supervisor for help.' , 'wordpress-word-trainer'),
    'new_word' => __( 'new word' , 'wordpress-word-trainer'),
    'back_to_menu' => __( 'back_to_menu' , 'wordpress-word-trainer'),
  ) );
  
}

?>